package com.youhp.spire.xls.demo.Charts.ManipulateChart;

import com.spire.xls.*;
import com.spire.xls.core.ITextBoxLinkShape;

public class AddTextBox {
    public static void main(String[] args) {
        //Create a workbook
        Workbook workbook = new Workbook();
        workbook.loadFromFile("data/AddTextBox.xlsx");

        //Get the first sheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the first chart
        Chart chart = sheet.getCharts().get(0);

        //Add a textbox
        ITextBoxLinkShape textbox = chart.getShapes().addTextBox();
        textbox.setWidth(1200);
        textbox.setHeight(320);
        textbox.setLeft(1000);
        textbox.setTop(480);
        textbox.setText("This is a textbox");

        //Save the result file
        workbook.saveToFile("output/AddTextBox.xlsx", ExcelVersion.Version2010);

    }
}
